﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Data.SqlClient;
using System.Data;

namespace UI6Yao
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }

        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
           
            
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            String gua = textBox1.Text.Trim();
            if (checkBoxIsYaoGua.IsChecked.Value)
            {
                this.userControl六爻起卦1.六爻起卦 = new ZYO.class六爻起卦(
                    ZYO.ZYOEnum.e起卦方法.摇卦,
                    DateTime.Now,
                    gua,
                    "求财");
            }
            else
            {
                this.userControl六爻起卦1.六爻起卦 = new ZYO.class六爻起卦(ZYO.ZYOEnum.e起卦方法.测字,
                    DateTime.Now,
                    gua,
                    "求财");
            }
        }

        private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
        {
            String gua = textBox1.Text.Trim();

            if (!checkBoxIsYaoGua.IsChecked.Value)
            {
                this.userControl六爻起卦1.六爻起卦 = new ZYO.class六爻起卦(ZYO.ZYOEnum.e起卦方法.测字,
                    DateTime.Now,
                    gua,
                    "求财");
            }
            
        }

        private void StockDataIni_Click(object sender, RoutedEventArgs e)
        {
            SqlConnection myConn = new SqlConnection("server=jeffrey-pc;database=Stockdb;Integrated Security=SSPI");
            myConn.Open();

            //SqlCommand myCommand = new SqlCommand("select [PK_DATE] From [dbo].[DateAll]"
            //                                        , myConn);
            //myCommand.CommandType = CommandType.Text;

            //SqlDataAdapter adapter = new SqlDataAdapter(myCommand);

            //DataSet dsDate = new DataSet();

            //adapter.Fill(dsDate);

            //foreach (DataRow rowDate in dsDate.Tables[0].Rows)
            //{
            //    DateTime dt = (DateTime)rowDate["PK_DATE"];

            //    ZYO.ZYDateTime zydt = new ZYO.ZYDateTime(dt);

            //    String updateStringFormart = " UPDATE [dbo].[DateAll] SET [Year] = '{1}',[Month] = '{2}',[Day] = '{3}',[Empty] = '{4}' WHERE [PK_Date] ='{0}'";
            //    String updateString = String.Format(updateStringFormart,
            //                                dt.ToString(),
            //                                zydt.JZYear.Name,
            //                                zydt.JZMonth.Name,
            //                                zydt.JZDay.Name,
            //                                zydt.旬空[0].Name + zydt.旬空[1].Name);

            //    SqlCommand myUpdateCommand = new SqlCommand(updateString, myConn);
            //    myUpdateCommand.CommandType = CommandType.Text;

            //    myUpdateCommand.ExecuteNonQuery();

            //}






            //for (int i = 1; i <= 60; i++)
            //{

            //    ZYO.class甲子 jz = new ZYO.class甲子(i);

            //    String updateStringFormart = "INSERT INTO [dbo].[DimJZ]([JZ])VALUES ('{0}')";
            //    String updateString = String.Format(updateStringFormart,
            //                                jz.Name);

            //    SqlCommand myUpdateCommand = new SqlCommand(updateString, myConn);
            //    myUpdateCommand.CommandType = CommandType.Text;

            //    myUpdateCommand.ExecuteNonQuery();
            //}



        }

        private void StockAnalysis_Click(object sender, RoutedEventArgs e)
        {

        }        
        private void qmdj_Click(object sender, RoutedEventArgs e)
        {
            WindowAnalysis a = new WindowAnalysis();
            a.Show();

        }

        
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            DateTime dt;

            if (DateTime.TryParse(textBoxDate.Text, out dt))
            {
                ZYO.ZYDateTime zydt = new ZYO.ZYDateTime(dt);
                labelDate.Content = zydt.Name + "" + zydt.旬空[0].Name + zydt.旬空[1].Name;

            }

        }
    }
}
